package com.hxzy.projectssmplus.exception;

/**
 * 自定义异常
 */
public class ServiceException extends RuntimeException{
    /**
     * 错误码(前端用)
     */
    private Integer code;

    /**
     * 错误提示(前端用)
     */
    private String msg;


    /**
     * 错误明细，内部调试错误（开发人员看的，写入到日志中的）
     *
     */
    private String detailMessage;

    /**
     * 空构造方法，避免反序列化问题
     */
    public ServiceException()
    {
    }

    public ServiceException(String msg)
    {
        this.code=500;
        this.msg = msg;
    }

    public ServiceException(String msg, Integer code)
    {
        this.msg = msg;
        this.code = code;
    }

    public String getDetailMessage()
    {
        return detailMessage;
    }

    public String getMessage()
    {
        return msg;
    }

    public Integer getCode()
    {
        return code;
    }

    public ServiceException setMessage(String message)
    {
        this.code=500;
        this.msg = message;
        return this;
    }

    public ServiceException setDetailMessage(String detailMessage)
    {
        this.code=500;
        this.detailMessage = detailMessage;
        return this;
    }
}
